#!/usr/bin/python
#-*- coding: utf-8 -*-
import smtplib
from email.mime.text import MIMEText

mail_host="smtp.163.com"
mail_user="lyccode"
mail_pass="299792458"
mail_postfix="163.com"

#functo make up a mime and send mail
def send_mail(to_list,sub,content):
	me = mail_user+"<"+mail_user+"@"+mail_postfix+">"
	msg = MIMEText(content)
	msg['Subject'] = sub
	msg['From'] = me
	msg['To'] = ";".join(to_list)
	try:
		s = smtplib.SMTP()
		s.connect(mail_host)
		s.login(mail_user,mail_pass)
		s.sendmail(me, to_list, msg.as_string())
		s.close()
		return True
	except Exception, e:
		print str(e)
		return False

if __name__ == '__main__':
	mailto_list = ["liuyuncheng@cdsf.com"]
	subject = "hellow"
	content = "hellow python"

	if send_mail(mailto_list,subject,content):
		print "success" 
	else:
		print "failed"
